package WaiBao;

import java.util.Arrays;

public class ZaiWei {
    public static void main(String[] args) {
        String[] name = {"成龙(班长)", "甑子丹(纪律委员)", "小李(学习委员)", "文章(体育委员)", "方文山", "周杰伦", "周润发", "周星驰", "张德彪", "李大胖", "李子墨", "张旭梦",
                "王焕之", "白居易", "宋正廷", "郭婷婷", "张碧城", "李浩男", "天浩楠", "董宇程", "徐宁宇", "李耀宇", "闫想", "闫嘟嘟", "严想", "王年年", "李念念", "张晓伟",
                "杨迪", "翟伟(学生)"};//考生本人: 翟伟(学生)
        int[] age = {20, 21, 20, 19, 19, 22,19, 21, 21, 19, 19, 18, 19, 21, 20, 19, 18, 20, 18, 18, 19, 19, 20, 20, 20, 19,22, 18,19, 21};//最后一位：考生年龄:21

        double[] wangle1 = {75, 76, 84, 84, 79, 69, 78, 89, 84, 80, 81, 84, 85, 89, 75, 68, 79, 70, 76, 84, 92, 91, 95, 65, 75, 74, 94, 74, 88, 95};
        double[] wangle2 = {79, 84, 99, 76, 75, 77, 79, 79, 81, 70, 70, 77, 86, 95, 60, 60, 76, 79, 64, 98, 72, 71, 95, 86, 76, 84, 84, 65, 81, 95};
        double[] wangle3 = {94, 76, 84, 85, 77, 66, 68, 74, 80, 80, 93, 87, 85, 65, 85, 68, 69, 96, 96, 93, 92, 81, 65, 95, 76, 87, 73, 71, 89, 96};


        double chukou1;//代表每个学生的总分
        double chukou2;//代表每个学生的平均分
//        for (int i = 0; i < 30; i++) {
//            chukou1 = wangle1[i] + wangle2[i] +wangle3[i];
//            chukou2 = (chukou1 * 1.0) / 3;
//            System.out.println(name[i] + "的总分为:" + chukou1);
//            System.out.println(name[i] + "的平均分为:" + chukou2);
//        }


        double eric1 = 0,eric2 = 0;
        double[] Arr = new double[30];
//        for (int i = 0; i < 30; i++) {
//            eric1 =wangle1[i] + wangle2[i] + wangle3[i];
//            eric2= (eric1 * 1.0) / 3;
//            Arr[i] = eric2;
//        }
//
//        for (int i = 0; i < Arr.length - 1; i++) {
//            for (int j = 0; j < Arr.length - i - 1; j++) {
//                if (Arr[j] < Arr[j + 1]) {
//                    double tep = Arr[j];
//                    Arr[j] = Arr[j + 1];
//                    Arr[j + 1] = tep;
//                }
//            }
//        }
//        System.out.println("前十名同学的成绩为:");
//        for (int i = 0; i < 10; i++) {
//            System.out.println(Arr[i]);
//        }



        double hai1 = 0,hai2 = 0, hai3 = 0;//计算每门课的平均分
        double demo1 = 0, demo2 = 0, demo3 = 0;//计算每门课标准差
        double meiren1 = 0,meiren2 = 0, meiren3 = 0;//计算每门课中位数
        double he = 0;
        for (int i = 0; i <wangle1.length; i++) {
            he += wangle1[i];
        }
        hai1 = (he * 1.0) / 30;
        System.out.println("生物化学的班级平均分为:" + hai1);
        double Sum = 0;
        for (int i = 0; i < wangle2.length; i++) {
            Sum += wangle2[i];
        }
        hai2 = (Sum * 1.0) / 30;
        System.out.println("物理化学的班级平均分为:" + hai2);
        double sum = 0;
        for (int i = 0; i < wangle3.length; i++) {
            sum += wangle3[i];
        }
        hai3 = (sum * 1.0) / 30;
        System.out.println("电子与电工技术的班级平均分为:" + hai3);


        double c1 = 0, c2 = 0, c3 = 0;
        for (int i = 0; i < wangle1.length; i++) {
            c1 += (wangle1[i] -hai1) * (wangle1[i] - hai1);
        }
        demo1 = Math.sqrt(c1*1.0/30);
        System.out.println("生物化学的班级标准差为:" + demo1);
        for (int i = 0; i < wangle2.length; i++) {
            c2 += (wangle2[i] - hai2) * (wangle2[i] - hai2);
        }
        demo2 = Math.sqrt(c2*1.0/30);
        System.out.println("物理化学的班级标准差为:" + demo2);

        for (int i = 0; i < wangle3.length; i++) {
            c3 += (wangle3[i] - hai3) * (wangle3[i] - hai3);
        }
        demo3 = Math.sqrt(c3*1.0/30);
        System.out.println("电子与电工技术的班级标准差为:" + demo3);
//////
////
////
        Arrays.sort(wangle1);
        Arrays.sort(wangle2);
        Arrays.sort(wangle3);
        meiren1 = (wangle1[14] + wangle2[15]) * 1.0 / 2;
        meiren2 = (wangle2[14] + wangle2[15]) * 1.0 / 2;
        meiren3 = (wangle3[14] + wangle3[15]) * 1.0 / 2;
        System.out.println("生物化学的中位数为:" + meiren1);
        System.out.println("物理化学的中位数为:" + meiren2);
        System.out.println("电子与电工技术的中位数为:" + meiren3);

    }
}
